package wypozyczalnia.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import wypozyczalnia.dao.HireDao;
import wypozyczalnia.domain.Hire;
import wypozyczalnia.domain.User;

@Service("hireService")
@Transactional
public class HireService {

	@Autowired
	private HireDao hireDao;

	public void create(Hire p_hire) {
		hireDao.save(p_hire);
	}

	public void deleteById(Integer p_id) {
		Hire hire = hireDao.getById(p_id);
		if (hire != null) {
			hireDao.delete(hire);
		}
	}

	public List<Hire> getallHires() {
		return hireDao.getAll();
	}

	public Hire getHireById(Integer p_id) {
		return hireDao.getById(p_id);
	}

	public void update(Hire p_hire) {
		hireDao.update(p_hire);
	}

	public List<Hire> getHiresForRaport() {
		return hireDao.getHiresForRaport();
	}

	public List<Hire> getHiresForUser(User user) {
		return hireDao.getHiresForUser(user);
	}

}
